package com.azt.front.action.product;

import com.azt.api.dto.hot.ProShopFloorExt;
import com.azt.api.dto.hot.ProShopHotExt;
import com.azt.api.dto.shop.ProSearchParam;
import com.azt.api.pojo.User;
import com.azt.api.service.ProductService;
import com.azt.front.utils.ContextUtil;
import com.azt.model.page.TPagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 商城首页
 * Created by 张栋 on 2017/2/2713:35
 */
@Controller
@RequestMapping("member")
public class MemberAction {


    @Autowired
    private ProductService productService;


    @RequestMapping("")
    public String member(ModelMap model) {
        List<ProShopFloorExt> floors = productService.getProShopFloor();
        model.put("floors", floors);
        //限时促销
        List<ProShopHotExt> hots = productService.getProShopHot();
        model.put("hots", hots);
        //最新发布商品


        //获取热销
        ProSearchParam proSearchParam = new ProSearchParam();
        proSearchParam.setPageNo(1);
        User user = ContextUtil.getUser();
        if(user==null){
            proSearchParam.setPageSize(4);
        }else{
            proSearchParam.setPageSize(6);
        }
        proSearchParam.setOrderType(0);//浏览量desc
        TPagination newProducts = productService.getProductList(proSearchParam);

        model.put("newproduct",newProducts.getList());


        model.put("user",user);
        return "product/member_index";
    }


}
